package com.yqw.spring1219.dp.filter;

import java.util.ArrayList;
import java.util.List;

/**
 * 责任链整体也是看作是一个Filter
 * @author abc
 *
 */
public class FilterChain implements Filter{
	private List<Filter> filters = new ArrayList<>();
	
	public FilterChain addFilter(Filter filter) {
		this.filters.add(filter);
		return this;
	}
	public String doFilter(String msg) {
		String r = msg;
		for (Filter filter : filters) {
			r = filter.doFilter(r);
		}
		return r;
	}
}
